<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加商品</title>
		<link rel="stylesheet" href="../../../resources/layui/css/layui.css" />
		<script type="text/javascript" src="../../../resources/layui/layui.js"></script>
		<script type="text/javascript" src="../../../resources/js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript" src="../../../resources/js/moxie.js"></script>
		<script type="text/javascript" src="../../../resources/js/plupload.full.min.js"></script>
		<script type="text/javascript" src="../../../resources/js/qiniu.js"></script>
		<script type="text/javascript" src="../../../resources/js/qiniu_img_upload.js"></script>

	</head>

	<body>
		<div id="" style="padding: 20px;width: 800px;margin: auto;">
			<form class="layui-form" action="">
				<div class="layui-form-item">
					<label class="layui-form-label">商品名称</label>
					<div class="layui-input-block">
						<input type="text" name="goodname" required lay-verify="required" placeholder="请输入商品名称" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">所需积分</label>
					<div class="layui-input-block">
						<input type="text" name="goodsocre" required lay-verify="required" placeholder="请输入商品所需积分" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">商品图片</label>
					<div class="layui-input-block">
						<div id="btn-uploader">
							<span id="pickfiles" class="layui-btn layui-btn-normal">选择文件</span>
							<div class="layui-progress layui-progress-big" lay-filter="demo" lay-showPercent="true" style="background:white;position:absolute;top:9px;width: 585px;margin-left: 100px;">
								<div class="layui-progress-bar" lay-percent="100%"></div>
							</div>
						</div>
					</div>
					<div>
						<img src="" name="articleImg" class="q_img" lay-verify="articleImg" style="width: 200px;height: 130px;display:none;margin-left: 109px;margin-top: 10px;" />
						<input type="hidden" name="img_src" value="" id="in_hiden" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">商品分类</label>
					<div class="layui-input-block">
						<select name="goodstype" lay-verify="required">
							<option value=""></option>
							<option value="0">吃的</option>
							<option value="1">玩的</option>
							<option value="2">用的</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">商品描述</label>
					<div class="layui-input-block">
						<textarea name="gooddesc" placeholder="请输入内容" class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="addgood">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>

		<script>
			$(document).ready(function() {
				getTokenMessage();
			});

			function getTokenMessage() {
				$.ajax({
					url: '/qiniu/fileUplaod.action',
					type: 'POST',
					data: {},
					cache: false,
					contentType: false, //不可缺
					processData: false, //不可缺
					dataType: 'json',
					success: function(data) {
						var obj = data;
						uploaderReady(obj.uptoken);
					}
				});
			}
			layui.use('form', function() {
				var form = layui.form;
				form.on('submit(addgood)', function(data) {
					layer.msg(JSON.stringify(data.field));
					return false;
				});
			});
		</script>
	</body>

</html>